﻿<%@ Page Title="Information Management System" Language="C#" MasterPageFile="~/Main.Master"
    AutoEventWireup="true" CodeBehind="UserManage.aspx.cs" Inherits="CARMS.Admin.UserManage" %>

<%@ Import Namespace="CARMSBusiness" %>
<%@ Import Namespace="CARMSBusiness.InterFace" %>
<%@ Import Namespace="CARMS" %>
<%@ Register Src="~/Controls/GridPager.ascx" TagName="GridPager" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script language="javascript" type="text/javascript">
        function showUserDetail(sender, args) {
            var userId = $attr(sender.get_selectedRow(), 'UserId');
            window.location = '<%=ResolveUrl(SiteUrls.Admin.EditUserInfo) %>?UserID=' + userId;
            return false;
        }


        function createUser() {
            $dialog('<%= ResolveUrl("~/Admin/EditUserInfo.aspx") %>', { width: 700, height: 250 }, function(result) {
                if (result) {
                    $get('<%=btnReload.ClientID %>').click();
                }
            });
        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <fieldset>
                <legend>Search Condition</legend>
                <table cellpadding="0" cellspacing="0" border="0">
                    <tr>
                        <td>
                            <vs:FormPanel ID="FormPanel1" runat="server" RepeatColumns="2" ColumnSpacing="5">
                                <Items>
                                    <vs:FormItem HeaderText="Login Name">
                                        <ContentTemplate>
                                            <asp:TextBox runat="server" ID="txtLoginName" MaxLength="50"></asp:TextBox>
                                        </ContentTemplate>
                                    </vs:FormItem>
                                    <vs:FormItem HeaderText="Full Name">
                                        <ContentTemplate>
                                            <asp:TextBox runat="server" ID="txtFullName" MaxLength="50"></asp:TextBox>
                                        </ContentTemplate>
                                    </vs:FormItem>
                                    <vs:FormItem HeaderText="Role">
                                        <ContentTemplate>
                                            <asp:DropDownList ID="chlRoles" runat="server">
                                            </asp:DropDownList>
                                        </ContentTemplate>
                                    </vs:FormItem>
                                    <vs:FormItem HeaderText="Department" Visible="false">
                                        <ContentTemplate>
                                            <asp:TextBox runat="server" ID="txtDepartment" MaxLength="50"></asp:TextBox>
                                        </ContentTemplate>
                                    </vs:FormItem>
                                </Items>
                            </vs:FormPanel>
                        </td>
                        <td valign="bottom">
                            <asp:Button runat="server" ID="btnSearch" Text="Search" OnClick="btnSearch_Click" />
                            <asp:Button runat="server" ID="btnViewAll" Text="View All" OnClick="btnViewAll_Click"
                                SkinID="Button80" />
                            <asp:Button runat="server" ID="btnCreateNew" Text="Create" />
                        </td>
                    </tr>
                </table>
            </fieldset>
            <fieldset>
                <legend>User List</legend>
                <div style="margin-top: 10px">
                    <vs:GridView ID="gridUsers" runat="server" AutoGenerateColumns="False" AllowSorting="true"
                        OnRowDataBound="gridUsers_RowDataBound" OnRowCommand="gridUsers_RowCommand">
                        <Columns>
                            <asp:TemplateField HeaderText="Edit">
                                <ItemTemplate>
                                    <asp:ImageButton ID="btnView" runat="server" SkinID="Modify" CommandName="ViewItem"
                                        CommandArgument='<%#Eval("UserID") %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <vs:BoundField HeaderText="Login Name" SortExpression="LoginName" HtmlEncode="true"
                                DataField="LoginName">
                            </vs:BoundField>
                            <vs:BoundField HeaderText="Full Name" SortExpression="FullName" DataField="FullName"
                                HtmlEncode="true">
                            </vs:BoundField>
                            <vs:BoundField HeaderText="Phone" SortExpression="Phone" DataField="Tel" HtmlEncode="true">
                            </vs:BoundField>
                            <vs:TemplateField HeaderText="Status" SortExpression="Status">
                                <ItemTemplate>
                                    <%#((bool)Eval("IsActived"))?"Active":"Inactive" %>
                                </ItemTemplate>
                            </vs:TemplateField>
                            <vs:TemplateField HeaderText="Roles" ItemStyle-Width="400px">
                                <ItemTemplate>
                                    <asp:Repeater ID="rptRoles" runat="server">
                                        <ItemTemplate>
                                            <%#Eval("RoleName") %>
                                        </ItemTemplate>
                                        <SeparatorTemplate>
                                            ,
                                        </SeparatorTemplate>
                                    </asp:Repeater>
                                </ItemTemplate>
                            </vs:TemplateField>
                            <asp:TemplateField HeaderText="Create Date" SortExpression="CreateDate">
                                <ItemTemplate>
                                    <%#((DateTime)Eval("CreateDate")).ToString(ApplicationConfiguration.DateFormat)%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Operation">
                                <ItemTemplate>
                                    <asp:ImageButton ID="ImageButton1" runat="server" SkinID="Confirm" CommandName="PermissionItem"
                                        CommandArgument='<%#Eval("UserID") %>' ToolTip="Permission Setting" />
                                    <asp:ImageButton ID="btnDelete" runat="server" SkinID="Delete" CommandName="DeleteItem"
                                        CommandArgument='<%#Eval("UserID") %>' OnClientClick="return ConfirmDeleteScript();" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </vs:GridView>
                    <asp:Button ID="btnReload" runat="server" SkinID="Hidden" OnClick="btnReload_Click" />
                    <uc1:GridPager ID="PageQueryAdapter1" runat="server" TargetControlID="gridUsers"
                        PageSize="100" OnPerformGetCondition="PageQueryAdapter1_PerformGetCondition"
                        OnPerformGetRecordCount="PageQueryAdapter1_PerformGetRecordCount" OnPerformGetPageData="PageQueryAdapter1_PerformGetPageData" />
                </div>
            </fieldset>
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
